﻿/*
' Copyright (c) 2014  Christoc.com
'  All rights reserved.
' 
' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
' TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
' THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
' CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
' DEALINGS IN THE SOFTWARE.
' 
*/

using System;
using System.Web;
using System.Web.UI.WebControls;
using CkSoftware.GroupMe.Sdk.Helpers.Authorization;
using CkSoftware.GroupMeChatModule.Components;
using CkSoftware.GroupMeChatModule.Constants;
using DotNetNuke.Entities.Modules;
using DotNetNuke.Entities.Modules.Actions;
using DotNetNuke.Framework;
using DotNetNuke.Security;
using DotNetNuke.Services.Exceptions;
using DotNetNuke.Services.Localization;
using DotNetNuke.UI.Utilities;

namespace CkSoftware.GroupMeChatModule
{
	/// -----------------------------------------------------------------------------
	/// <summary>
	/// The View class displays the content
	/// 
	/// Typically your view control would be used to display content or functionality in your module.
	/// 
	/// View may be the only control you have in your project depending on the complexity of your module
	/// 
	/// Because the control inherits from CkSoftwareGroupMeChatModuleModuleBase you have access to any custom properties
	/// defined there, as well as properties from DNN such as PortalId, ModuleId, TabId, UserId and many more.
	/// 
	/// </summary>
	/// -----------------------------------------------------------------------------
	public partial class View : CkSoftwareGroupMeChatModuleModuleBase, IActionable
	{
		protected PermanentGroupMeLogon PermanetGroupMeLogon;

		protected string ShowMessageBoxOnBottom
		{
			get
			{
				var showBoxOnBottomValue = Settings[ModulePropertyKeys.ShowMessageBoxOnBottom] ?? false;
				return showBoxOnBottomValue.ToString().ToLowerInvariant();
			}
		}

		protected void Page_Load(object sender, EventArgs e)
		{
			try
			{
				ServicesFramework.Instance.RequestAjaxAntiForgerySupport();

				GroupMeChat.Attributes.Add("data-message-box-on-bottom", ShowMessageBoxOnBottom);
				GroupMeChat.Attributes.Add("data-messages-height", (Settings[ModulePropertyKeys.MessagesHeight] ?? 625).ToString());
			}
			catch (Exception exc) //Module failed to load
			{
				Exceptions.ProcessModuleLoadException(this, exc);
			}
		}

		public ModuleActionCollection ModuleActions
		{
			get
			{
				var actions = new ModuleActionCollection();
				return actions;
			}
		}
	}
}